﻿<Local:NavigationView
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    x:Class="SeriesManager.View.ActorView"
    NavigationCacheMode="Enabled"
    
    xmlns:Local="using:SeriesManager.View"
    xmlns:Converter="using:SeriesManager.Converter">
    
    <Page.Resources>
        <Converter:BooleanVisibilityConverter x:Key="BooleanVisibilityConverter" />        
        <DataTemplate x:Key="dataTemplate">
            <Grid Background="Black">
                <Image Source="{Binding Image.LocalPath, TargetNullValue=/Assets/ActorsViewPlaceholder.png}" Stretch="UniformToFill" />

                <Border Background="#A30707" VerticalAlignment="Bottom" Opacity="0.8">
                    <StackPanel Margin="5" Orientation="Vertical">
                        <TextBlock Text="{Binding Name}" Foreground="White" FontSize="19" TextTrimming="WordEllipsis" HorizontalAlignment="Stretch"/>
                        <TextBlock Text="{Binding Role}" Foreground="White" FontSize="19" TextTrimming="WordEllipsis" HorizontalAlignment="Stretch"/>
                    </StackPanel>
                </Border>
            </Grid>
        </DataTemplate>
    </Page.Resources>

    <Grid>
        <Grid.ChildrenTransitions>
            <TransitionCollection>
                <EntranceThemeTransition/>
            </TransitionCollection>
        </Grid.ChildrenTransitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <GridView
            x:Name="gridView"
            Style="{StaticResource GridViewStyle}"
            Grid.RowSpan="2"
            Padding="116,140,40,30"
            ItemsSource="{Binding View}"
            SelectionMode="None"
            IsItemClickEnabled="False"
            ItemTemplate="{StaticResource dataTemplate}">
            <GridView.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapGrid ItemWidth="193" ItemHeight="290" />
                </ItemsPanelTemplate>
            </GridView.ItemsPanel>
        </GridView>

        <ListView
            x:Name="listView"
            Style="{StaticResource ListViewStyle}"
            Grid.RowSpan="2"
            Padding="30,0"
            Margin="0,140,0,0"
            ItemsSource="{Binding View}"
            SelectionMode="None"
            IsItemClickEnabled="False"
            IsSwipeEnabled="False"
            ItemTemplate="{StaticResource dataTemplate}"
            Visibility="Collapsed">
            <ListView.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapGrid ItemWidth="200" ItemHeight="300" Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </ListView.ItemsPanel>
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="Margin" Value="3" />
                </Style>
            </ListView.ItemContainerStyle>
        </ListView>

        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="120"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <AppBarButton Icon="Back" Height="95" Margin="10,46,10,0" Command="{Binding BackCommand}" Visibility="{Binding IsEnabled, Converter={StaticResource BooleanVisibilityConverter}, RelativeSource={RelativeSource Mode=Self}}"/>
            <TextBlock x:Name="Header" x:Uid="ActorsHeader" Style="{StaticResource HeaderTextBlockStyle}" Grid.Column="1" IsHitTestVisible="false" TextWrapping="NoWrap" VerticalAlignment="Bottom" Margin="0,0,30,40" TextTrimming="CharacterEllipsis"/>
        </Grid>

        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup>
                <VisualState x:Name="Landscape768" />
                <VisualState x:Name="Landscape500">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="gridView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="listView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</Local:NavigationView>